<template>
  <div>
    <MkBillPanel :bill="ctx.zhuBiao" ref='billPanelRef' printCode='traLinChuangFaXue' v-loading="ctx.loading">
      <template #button>
        <MkButtonEdit @click="edit" :isEdit="isCanEdit" />
        <MkButtonSubmit @click="submit" :loading="ctx.loading" :isEdit="ctx.isEdit" />
        <MkButtonMore>
          <a-menu-item @click="cancel">作废</a-menu-item>
          <a-menu-item @click="billPanelRef.showCaoZuo()">操作记录</a-menu-item>
        </MkButtonMore>
        <MkButtonMore title="打印" @click="print" icon="ele-Printer">
          <a-menu-item @click="print">打印</a-menu-item>
        </MkButtonMore>
      </template>
      <template #info>
        <MkForm :model='ctx.zhuBiao' ref='formRef' formId='TraXueXingFuHe' :col="4">
          <MkInput v-model="ctx.zhuBiao.biaoBenHao" prop="biaoBenHao" label="标本号" :isEdit="ctx.isEdit" />
          <MkSelectEnum label="ABO复核结果" v-model="ctx.zhuBiao.aboFuHeJieGuo" prop='aboFuHeJieGuo' :isEdit="ctx.isEdit"
            :enumType="enumType.ABOFuHeJieGuo" />
          <MkSelectEnum label="Rh(D)复核结果" v-model="ctx.zhuBiao.rhDFuHeJieGuo" prop='rhDFuHeJieGuo' :isEdit="ctx.isEdit"
            :enumType="enumType.RhDFuHeJieGuo" />
          <MkInput v-model="ctx.zhuBiao.aboJianDing" prop="aboJianDing" label="ABO鉴定方法" :isEdit="ctx.isEdit" />
          <MkInput v-model="ctx.zhuBiao.rhDJianDing" prop="rhdJianDing" label="Rh(D)鉴定方法" :isEdit="ctx.isEdit" />
          <MkSelectEnum label="抗筛结果" v-model="ctx.zhuBiao.kangShaiJieGuo" prop='kangShaiJieGuo' :isEdit="ctx.isEdit"
            enumType="KangShaiJieGuo" />
          <MkSelectUser v-model="ctx.zhuBiao.jianYanRenId" prop="jianYanRenId" label="检验人" :isEdit="ctx.isEdit" />
          <MkSelectUser v-model="ctx.zhuBiao.fuHeRenId" prop="fuHeRenId" label="复核人" :isEdit="ctx.isEdit" />
          <MkDatePicker v-model="ctx.zhuBiao.jianYanShiJian" prop="jianYanShiJian" label="检验时间" :isEdit="ctx.isEdit" />
        </MkForm>
      </template>
    </MkBillPanel>
    <ListDrawerComponent ref="historyRef" @load="loadEntity" :parentWidth="setupContainerWidthLogic" />
  </div>
</template>

<script setup lang="ts" name="traXueXingFuHe">
import ListDrawerComponent from './list.vue'; // 给它一个别名，方便区分
import { TraShenQingDanOutput } from '/@/api/tra/TraShenQing';
import { enumType } from '/@/const';
import { useTraXueXingFuHe } from './index'
const {
  ctx, formRef, listRef, billPanelRef, editPageRef,
  newEntity, loadEntity, submit, cancel, setupContainerWidthLogic,
  print, handleGetShenQing, mkPatientFormRef, edit,
  initProps, initEmits,
  isCanEdit
} = useTraXueXingFuHe()

const props = defineProps({
  billId: { // 单号
    type: String,
    default: '',
  },
  shenQingDanInfo: {
    type: Object as PropType<TraShenQingDanOutput>,
    default: () => { },
  },
});
onMounted(() => {
  if (props.billId) {
    loadEntity({ id: props.billId });
  }
})

initProps(props);
const emits = defineEmits(['submitCallBack'])
initEmits(emits)
/**
 * 暴露出去好联动
 */
defineExpose({
  loadEntity
});
</script>